<?php
namespace app\common\tool;

class Password extends Base {
	//生成盐值
	public static function get_salt() {
		return substr(md5(time()), -4);
	}

	//加密密码
	public static function encryption($password, $salt = '', $returnSalt = false) {
		if(empty($salt)) {
			$salt = static::get_salt();
		}
		$password = md5(md5($password) . $salt);
		if($returnSalt) {
			return ['password' => $password, 'salt' => $salt];
		} else {
			return $password;
		}
	}
}
